<script>
import {routes} from "@/router/viewsRouter";

export default {
  name: "layout",
  data() {
    return {}
  },
  computed: {
    routeList() {
      return routes[0].children;
    },
    path() {
      return this.$route.path
    }
  },
  methods: {
    routerGo(item) {
      if (this.path !== item.path) {
        this.$router.push(item.path)
      }
    }
  }
}
</script>

<template>
  <div class="layout">
    <div class="menu">
      <template v-for="(item,index) in routeList">
        <div :class="{'active':path===item.path}" class="item" :key="index" @click="routerGo(item)">
          {{ item.name }}
        </div>
      </template>
    </div>
    <div class="content">
      <div>
        <router-view/>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.layout {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  flex-wrap: nowrap;

  $menuWidth: 400px;

  .menu {
    width: $menuWidth;
    height: 100%;
    background: #fff;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 0 10px;
    box-sizing: border-box;
    border-top: 40px solid #6f89ea;

    .item {
      width: 100%;
      height: 40px;
      line-height: 40px;
      padding: 0 15px;
      box-sizing: border-box;
      background: #fff;
      cursor: pointer;
      font-size: 16px;
    }

    .active {
      background: #f2f2f2;
    }
  }

  .content {
    width: calc(100% - #{$menuWidth});
    height: 100%;
    background: #f2f2f2;
    padding: 10px;
    box-sizing: border-box;

    > div {
      background: white;
      padding: 10px;
      box-sizing: border-box;
      width: 100%;
      height: 100%;
    }
  }
}
</style>
